package com.gxa.jjty.admin.service.impl;

import com.gxa.jjty.admin.service.RoyaltyService;
import com.gxa.jjty.core.common.ExceptionCode;
import com.gxa.jjty.core.exception.BusinessException;
import com.gxa.jjty.core.pojo.Royalty;
import com.gxa.jjty.core.service.impl.BaseServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import tk.mybatis.mapper.common.Mapper;
import tk.mybatis.mapper.entity.Example;

import java.util.Map;

@Service
@Transactional(rollbackFor = Throwable.class)
public class RoyaltyServiceImpl extends BaseServiceImpl<Royalty> implements RoyaltyService {


    @Autowired
    Mapper<Royalty> royaltyMapper;


    @Override
    public void updateRoyalty(Long phyId) throws BusinessException {
        Royalty royalty = new Royalty();
        royalty.setRoyaltyStatus(0);
        Example example = new Example(Royalty.class);
        Example.Criteria criteria = example.createCriteria();
        criteria.andEqualTo("royaltyStatus",0);
        int i = royaltyMapper.updateByExample(royalty, example);
        if (i != 1){
            throw new BusinessException(ExceptionCode.SETTLEMENT_FAILURES);
        }


    }
}
